﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Presentation.Models.ProjectViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	<%: Model.Project.Name %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2><%: Model.Project.Name %></h2>

    <%: Model.Project.Description %>

    <h3>Details</h3>

        <div>
                
            <table>
                
                <tr>
                    <td>
                        <%: Html.LabelFor(m => m.Project.Status)%>:
                    </td>
                    <td align="center">
                        <img src="../../Assets/<%: Model.Project.Status.StatusIndicator %>.png" height="20px" width="20px" alt="<%: Model.Project.Status.StatusIndicator %>" />
                    </td>
                </tr>
               
                <% 
           
                    foreach (var formElement in Model.Form.FormElements)
                    {
                        var index = Model.Project.GetDetailIndex(formElement.Name);
                        
                        if (index != -1)
                        { 
                            var detail = Model.Project.Details[index];
                            
                            if (formElement.Type.Equals(Domain.Model.FormElement.TYPE_CHAR))
                            { 
                            %>
                                        
                                <tr>
                                            
                                    <td>
                                        <%: Html.Label(Model.Project.Details[index].Name) %>:
                                    </td>
                                    <td>
                                        <%: Html.Label(Model.Project.Details[index].Value) %>
                                    </td>

                                </tr>
                                        
                            <%
                            }
                            if (formElement.Type.Equals(Domain.Model.FormElement.TYPE_NUMERIC))
                            {
                            %>
                                        
                                <tr>
                                            
                                    <td>
                                        <%: Html.Label(Model.Project.Details[index].Name) %>:
                                    </td>
                                    <td>
                                        <%: Html.Label(Model.Project.Details[index].Value) %>
                                    </td>

                                </tr>
                                        
                            <%
                            }
                            if (formElement.Type.Equals(Domain.Model.FormElement.TYPE_DATE))
                            {
                            %>
                                        
                                <tr>
                                            
                                    <td>
                                        <%: Html.Label(Model.Project.Details[index].Name) %>:
                                    </td>
                                    <td>
                                        <%: Html.Label(Model.Project.Details[index].Value) %>
                                    </td>

                                </tr>
                                        
                            <%
                            }
                        }
                    }
                    
                %>

            </table>

        </div>

    <div>
        <p>
        <% if (Model.ProgramId > 0)
           { %>
            <%: Html.ActionLink("Back to program", "View", "Program", new { id = Model.ProgramId }, null) %>
           <% }
           else
           { %>
            <%: Html.ActionLink("Back to portfolio", "Overview", "Portfolio") %>
           <% }
        %> 
        <% if (Helpers.IsAdmin(this)){%> | <%: Html.ActionLink("Edit", "Edit", "Project", new { id = Model.Project.Id }, null) %>
        <% } %>
        </p>
    </div>

    <table>
        <tr>
            <th>Subprojects</th>
            <th>Tasks</th>
        </tr>
        <tr valign="top">
            <td>
                <% Html.RenderPartial("ReadOnlySubprojectList", Model.Project.Subprojects); %>
            </td>
            <td>
                <% Html.RenderPartial("ReadOnlyTaskList", Model.Project.Tasks); %>
            </td>
        </tr>
    </table>

</asp:Content>
